package com.unidt.www.framework.common.util.object.plug;

import com.unidt.www.framework.common.util.object.annotation.BeanField;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author sk
 * @Description:
 * @Date 2022/11/30 15:02
 **/
@Data
public class Address {

    @BeanField(value = "province",cls =SimpleVo.class )
    private  SimpleVo  province;

    @BeanField(value = "city",cls =SimpleVo.class)
    private  SimpleVo  city;

    @BeanField(value = "area",cls =SimpleVo.class)
    private  SimpleVo  area;

    public AddressDetail getDetail(){
        AddressDetail addressDetail =new AddressDetail();

        this.province = this.province==null?new SimpleVo():this.province;
        this.city = this.city==null?new SimpleVo():this.city;
        this.area = this.area==null?new SimpleVo():this.area;

        Map<String,Object> map = new HashMap<>();
        addressDetail.setProvinceCode(this.province.getCode());
        addressDetail.setProvince(this.province.getValue());

        addressDetail.setCityCode(this.city.getCode());
        addressDetail.setCity(this.city.getValue());

        addressDetail.setAreaCode(this.area.getCode());
        addressDetail.setArea(this.area.getValue());

        return  addressDetail;
    }
}
